﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;

/// <summary>
/// Summary description for SanPhamDetails
/// </summary>
public class SanPhamDetails
{
    Connection conn = new Connection();

    public SanPham getDetail(string id) {
        conn.openCon();
        SanPham objSP = new SanPham();;
        string sql =string.Format("Select * from SanPham where masanpham='B00001'",id);
        SqlCommand cmd = new SqlCommand(sql,conn.getCon());
        //cmd.Parameters.Add("@id", System.Data.SqlDbType.VarChar,20).Value = id;
        SqlDataReader reader = cmd.ExecuteReader();
        if (reader.Read())
        {
           
            objSP.Sanphamid = reader.GetString(0);
            objSP.Giaban = reader.GetFloat(1);
            objSP.Ngaycapnhat = reader.GetDateTime(2);
            objSP.Loaid = reader.GetInt32(3);
            objSP.Xoa = reader.GetBoolean(4);
            objSP.Gioithieu = reader.GetString(5);
            objSP.Chucnangid = reader.GetInt32(6);
            objSP.Nhanhieuid = reader.GetInt32(7);
        }
        reader.Close();
        conn.closeCon();
        return objSP;
    }
}